vtd: move some x86-dependent functions into x86-specific directory.
authorKeir Fraser <keir.fraser@citrix.com>
Mon, 13 Oct 2008 09:09:09 +0000 (10:09 +0100)
committerKeir Fraser <keir.fraser@citrix.com>
Mon, 13 Oct 2008 09:09:09 +0000 (10:09 +0100)
Signed-off-by: Anthony Xu <anthony.xu@intel.com>
Signed-off-by: Dexuan Cui <dexuan.cui@intel.com>
xen/drivers/passthrough/vtd/iommu.c
xen/drivers/passthrough/vtd/vtd.h
xen/drivers/passthrough/vtd/x86/vtd.c

index c16d084776c5dbf811fe0142bbeab270c16f0ee0..48c7463663045bfbe28be3ca75ff53594fd89f37 100644 (file)
@@ -123,7 +123,7 @@ static void __iommu_flush_cache(void *addr, int size)
         return;
 
     for ( i = 0; i < size; i += clflush_size )
-        clflush((char *)addr + i);
+        cacheline_flush((char *)addr + i);
 }
 
 void iommu_flush_cache_entry(void *addr)
@@ -525,7 +525,7 @@ void iommu_flush_all(void)
     struct acpi_drhd_unit *drhd;
     struct iommu *iommu;
 
-    wbinvd();
+    flush_all_cache();
     for_each_drhd_unit ( drhd )
     {
         iommu = drhd->iommu;
@@ -962,8 +962,7 @@ static int iommu_alloc(struct acpi_drhd_unit *drhd)
         return -ENOMEM;
     }
 
-    set_fixmap_nocache(FIX_IOMMU_REGS_BASE_0 + nr_iommus, drhd->address);
-    iommu->reg = (void *)fix_to_virt(FIX_IOMMU_REGS_BASE_0 + nr_iommus);
+    iommu->reg = map_to_nocache_virt(nr_iommus, drhd->address);
     iommu->index = nr_iommus++;
 
     iommu->cap = dmar_readq(iommu->reg, DMAR_CAP_REG);
@@ -1768,7 +1767,7 @@ int intel_vtd_setup(void)
         return -ENODEV;
 
     spin_lock_init(&domid_bitmap_lock);
-    clflush_size = get_clflush_size();
+    clflush_size = get_cache_line_size();
 
     for_each_drhd_unit ( drhd )
         if ( iommu_alloc(drhd) != 0 )
index 6aa8cf59ccebd789c40ab52c670ac955211ee1cc..84cd2e5f8a4765cd93a5128deb261e0ff55d85af 100644 (file)
@@ -97,7 +97,10 @@ struct msi_msg_remap_entry {
     u32        data;           /* msi message data */
 };
 
-unsigned int get_clflush_size(void);
+unsigned int get_cache_line_size(void);
+void cacheline_flush(char *);
+void flush_all_cache(void);
+void *map_to_nocache_virt(int nr_iommus, u64 maddr);
 u64 alloc_pgtable_maddr(void);
 void free_pgtable_maddr(u64 maddr);
 void *map_vtd_domain_page(u64 maddr);
index c1cea803259f576a797a0707346a2650e60999e6..2c931eb64c632047e0e404292673cffd6962e193 100644 (file)
@@ -60,11 +60,27 @@ void free_pgtable_maddr(u64 maddr)
         free_domheap_page(maddr_to_page(maddr));
 }
 
-unsigned int get_clflush_size(void)
+unsigned int get_cache_line_size(void)
 {
     return ((cpuid_ebx(1) >> 8) & 0xff) * 8;
 }
 
+void cacheline_flush(char * addr)
+{
+    clflush(addr);
+}
+
+void flush_all_cache()
+{
+    wbinvd();
+}
+
+void *map_to_nocache_virt(int nr_iommus, u64 maddr)
+{
+    set_fixmap_nocache(FIX_IOMMU_REGS_BASE_0 + nr_iommus, maddr);
+    return (void *)fix_to_virt(FIX_IOMMU_REGS_BASE_0 + nr_iommus);
+}
+
 struct hvm_irq_dpci *domain_get_irq_dpci(struct domain *domain)
 {
     if ( !domain )